//BC153 [NOIP2010]数字统计
//使用Scanner输入sout输出35ms，使用自定义输入输出10ms
import java.util.*;
import java.io.*;

public class Main {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static void main(String[] args) throws IOException{

        int left = in.nextInt();
        int right = in.nextInt();
        int res = 0;
        for (int i = left; i <= right; i++) {
            int num = i;
            while (num > 0) {
                int a = num % 10;
                if (a == 2) {
                    res++;
                }
                num /= 10;
            }
        }
        out.print(res);
        out.close();
    }



    //NC313 两个数组的交集
    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        ArrayList<Integer> res=new ArrayList<>();
        HashSet<Integer> set=new HashSet<>(nums1);
        for(int i=0;i<nums2.size();i++){
            int a=nums2.get(i);
            if(set.contains(a)&&!res.contains(a)){
                res.add(a);
            }
        }
        return res;
    }



    //AB5 点击消除
    public static void main1(String[] args) throws IOException {
        String s = in.next();
        Stack<Character> stack = new Stack<>();
        StringBuffer res = new StringBuffer();
        stack.add(s.charAt(0));
        for (int i = 1; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (stack.isEmpty()) {
                stack.add(ch);
            } else {
                if (stack.peek() == ch) {
                    stack.pop();
                } else {
                    stack.add(ch);
                }
            }

        }
        if (stack.isEmpty()) {
            System.out.print(0);
        } else {
            while (!stack.isEmpty()) {
                res.append(stack.pop());
            }
            out.print(res.reverse());
        }
        out.close();
    }
}
class Read { // 自定义快速读入
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    String nextLine() throws IOException {
        return bf.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}



